package com.yi.wood.utils;

import java.util.Base64;

/**
 * Created by moyi on 2019/4/4 17:53
 *
 * @author moyi
 */
public class StringTokenUtil {

    private static final String PREFIX = "TOKEN-";

    public static String prefix(Long flag){
        return PREFIX+flag;
    }

    public static String unPrefix(String token){
        int index = token.indexOf(PREFIX);
        return token.substring(index);
    }

    private static String getToken(String code){
        byte[] bytes =  Base64.getEncoder().encode(code.getBytes());
        return new String(bytes);
    }

    public static String getToken(String code, String id){
        return getToken(code)+id;
    }
}
